#include <sys/types.h>

#include <sys/stat.h>

#include <fcntl.h>

#include <unistd.h>

#include <stdio.h>

#include <stdlib.h>



void main(int argc,char *argv[])

{

    int count=0,m,n,x;

    char temp;

    x=atoi(argv[1]);//字符型转换整形，命令行读取

    m=open(argv[2],O_RDONLY,0);

    if(m==-1)

        printf("not found");

    while(read(m,&temp,1)!=0)

    {

        if(temp=='\n')

        {

            count++;

        }

    }

    x=count-x;

    count=0;

    n=close(m);

    if(n==-1)

        printf("文件关闭失败");

    m=open(argv[2],O_RDONLY,0);

    if(m==-1)

        printf("not found");

    while(read(m,&temp,1)!=0)

    {

        if(temp=='\n')

        {

            count++;

        }

        if(count>=x)

        {

            printf("%c",temp);

        }

    }

    printf("\n");

    n=close(m);

    if(n==-1)

        printf("文件关闭失败");

}
